import config from "@/config"
import http from "@/utils/request"

export default {
    getList: {
        url: `${config.API_URL}/displayMaterial/list`,
        name: "获取材料",
        get: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.get(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },

    add: {
        url: `${config.API_URL}/displayMaterial/add`,
        name: "添加材料",
        post: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.post(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },
    update: {
        url: `${config.API_URL}/displayMaterial/update`,
        name: "修改材料",
        post: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.post(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },
    delete: {
        url: `${config.API_URL}/displayMaterial/delete`,
        name: "删除材料",
        post: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.postParam(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },
    isDisable: {
        url: `${config.API_URL}/displayMaterial/disable`,
        name: "启用/禁用数据",
        post: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.postParam(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },

    getType: {
        url: `${config.API_URL}/displayType/list`,
        name: "获取材料类型",
        get: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.get(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },
    updateType: {
        url: `${config.API_URL}/displayType/update`,
        name: "修改材料类型",
        post: function (data = {}) {
            return new Promise((resolve, reject) => {
                http.post(this.url, data).then((response) => {
                    resolve(response)
                }).catch((error) => {
                    resolve(error.data)
                })
            })
        }
    },
}